<template>
  <div class="index-box" ref="index">

        <div class="search" ref="search">
         <el-form :inline="true" :model="searchForm" size="small" ref="searchForm" @submit.native.prevent
           class="demo-form-inline" id="searchBox">
           <el-form-item prop="code">
               <el-input v-model="searchForm.code" clearable placeholder="请输入提取编号"></el-input>
           </el-form-item>

           <el-form-item prop="orderTime">
             <el-date-picker v-model="searchForm.orderTime" type="daterange" align="right" unlink-panels range-separator="至"
               start-placeholder="申请开始日期" end-placeholder="申请结束日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
               :picker-options="pickerOptions">
             </el-date-picker>
           </el-form-item>
           <el-form-item prop="updateTime">
             <el-date-picker v-model="searchForm.updateTime" type="daterange" align="right" unlink-panels range-separator="至"
               start-placeholder="审核开始日期" end-placeholder="审核结束日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
               :picker-options="pickerOptions">
             </el-date-picker>
           </el-form-item>


           <el-form-item class="clearfix">
             <el-button type="primary" @click="handleSearch()" icon="el-icon-search">查询</el-button>
             <el-button icon="el-icon-refresh" size="small" @click="resetQuery">重置</el-button>
           </el-form-item>


         </el-form>
        </div>
        <div class="actionBtn" ref="actionBtn">
          <div class="actionBtnLeft">
            <el-radio-group v-model="searchForm.audit" size="small" style="margin-right: 15px;">
              <el-radio-button :label="item.id" v-for="item in auditList">{{item.name}}</el-radio-button>
            </el-radio-group>
            <el-radio-group v-model="searchForm.member" size="small">
              <el-radio-button :label="item.id" v-for="item in memberList">{{item.name}}</el-radio-button>
            </el-radio-group>
          </div>
          <div class="actionBtnRight">
             <MyRefresh/>
              <MyTableColumnSet :tableColumn.sync="tableColumn" :hideTableColumn.sync="hideTableColumn" :tableColumnType.sync="tableColumnType"></MyTableColumnSet>
          </div>
        </div>
        <div class="table" ref="table">
          <el-table :data="dataList" style="width: 100%;"order v-loading="loading" :height="tableHeight" @selection-change="handleSelectionChange" default-expand-all>
            <!-- <el-table-column type="selection" width="55"></el-table-column> -->
            <el-table-column prop="goodsName" label="提取编号" v-if="!hideTableColumn.includes('code')"></el-table-column>
            <el-table-column prop="goodsName" label="申请前可提金额(元)" v-if="!hideTableColumn.includes('upMoneyQ')"></el-table-column>
            <el-table-column prop="goodsName" label="申请提取金额(元)" v-if="!hideTableColumn.includes('upMoney')"></el-table-column>
            <el-table-column prop="goodsName" label="服务费(元)" v-if="!hideTableColumn.includes('serviceCharge')"></el-table-column>
            <el-table-column prop="goodsName" label="实际到账金额(元)" v-if="!hideTableColumn.includes('practicalMoney')"></el-table-column>
            <el-table-column prop="goodsName" label="审核人(工号)" v-if="!hideTableColumn.includes('auditCode')"></el-table-column>
            <el-table-column prop="salePrice" label="状态" v-if="!hideTableColumn.includes('status')">
              <template slot-scope="scope">
                 <el-tag :type="scope.row.listClass">{{scope.row.statusName}}</el-tag>
              </template>
            </el-table-column>
            <el-table-column prop="salePrice" label="申请时间" v-if="!hideTableColumn.includes('applyTime')">
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.createTime) }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="statusName" label="审核时间" v-if="!hideTableColumn.includes('auditTime')">
                <template slot-scope="scope">
                  <span>{{ parseTime(scope.row.createTime) }}</span>
                </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="page" ref="page">
          <MyPagination
             :total="total"
             :page.sync="searchForm.pageNum"
             :limit.sync="searchForm.pageSize"
             @pagination="dataInfo"
           />
        </div>

  </div>
</template>

<script>
  import common from '@/api/api';
  import {orderList,getOrderQuantity,orderGetAfterSaleInfo} from '@/api/getData'
  import option from '../../common/option.js';

  export default {
    data() {
      return {
        loading: false,
        userLoading: false,
        searchForm: {
          code: '',
          orderTime:[],
          startOrderTime:'',
          endOrderTime:'',
          updateTime:[],
          startUpdateTime:'',
          endUpdateTime:'',

          pageNum: 1,
          pageSize: 20,
        },
        tableColumn:[{
            name:'提取编号',
            value:'code'
        },{
            name:'申请前可提金额(元)',
            value:'upMoneyQ'
        },{
            name:'申请提取金额(元)',
            value:'upMoney'
        },{
            name:'服务费(元)',
            value:'serviceCharge'
        },{
            name:'实际到账金额(元)',
            value:'practicalMoney'
        },{
            name:'审核人(工号)',
            value:'auditCode'
        },{
            name:'状态',
            value:'status'
        },{
            name:'申请时间',
            value:'applyTime'
        },{
            name:'审核时间',
            value:'auditTime'
        }],
        hideTableColumn:[],/*自定义表格列需要隐藏的*/
        tableColumnType:'staffManagement',/*自定义表格列类型传参*/
        tableHeight:400,//table 高度
        dataList:[{name:'333',val:4}],
        total: 0,
        multipleSelection: '',
        dialogTitle: '',

      }
    },
    computed: {
      pickerOptions: () => {
        return option.pickerOptions;
      }
    },
    mounted() {
      //this.getSelect();
      this.dataInfo();
      this.$nextTick(() => {
          this.tableHeight = this.$refs.index.offsetHeight  - this.$refs.search.offsetHeight  - this.$refs.page.offsetHeight - 70;
      })
    },
    methods: {
      getSelect(){
        getOrderQuantity({
          orderType:this.searchForm.orderType
        }).then((result) => {
          this.menuList = result.data;
        });
      },

      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("searchForm");
        this.dataInfo();
      },

      async dataInfo() {
        try {
          let data = this.searchForm;
          if(data.orderTime.length){
            data.startOrderTime = data.orderTime[0];
            data.endOrderTime = data.orderTime[1];
          }
          if(data.updateTime.length){
            data.startUpdateTime = data.updateTime[0];
            data.endUpdateTime = data.updateTime[1];
          }

          this.loading = true;
          
          const result = await orderList(data);
          if (result.code == 200) {
            this.total = result.total;
            this.dataList = result.rows;
          } else {
            this.$message.error(result.msg);
          }

          this.loading = false;
        } catch (err) {
          this.loading = false;
          console.log(err)
        }
      },

      handleSearch() {
        this.searchForm.pageNum = 1;
        this.dataInfo();
      },

      handleSelectionChange(val) {
        this.multipleSelection = val;
      },

    }
  }
</script>

<style scoped lang="scss">
  .tips{
    margin:0px;
  }
    .activeCheckedBox{
      border-top: 1px solid #ddd;
      padding:10px;
      height:52px;
      .el-tag{
        margin-right:10px;
      }
    }
    .menuList{
      display: flex;
      margin-bottom: 15px;
      .menu-item{
        flex:1;
        padding:20px 20px 10px 20px;
        border:1px solid #DCDFE6;
        border-right: none;
        cursor: pointer;
        .numberBox{
          display:flex;
          justify-content:center;
        }
        .tipsNumber{
           font-size: 12px;
           height: 18px;
           line-height: 18px;
           padding: 0 6px;
           text-align: center;
           white-space: nowrap;
           position:absolute;
           background:#FF2F43;
           border-radius: 10px;
           right: -16px;
           top: -6px;
           color:#fff;
        }
        .number{
          font-size: 32px;
          position:relative;
        }
        .text{
          font-size: 16px;
          color:#333333;
          text-align: center;
        }
      }
    }
    .menuList .menu-item:last-child{
      border-right: 1px solid #DCDFE6;
    }
    .menuList .menu-item:hover{
      background-color:#D8E4DD;
    }
     .menuList .menu-item.active{
        background-color: #D8E4DD;
     }


    .table /deep/ .el-table__expanded-cell{
     background: #FAFCFB;
      padding:0 50px;
    }
    .table /deep/ .el-table__expanded-cell:hover{
     background: #FAFCFB!important;
    }
    .table /deep/ .el-table__expanded-cell .el-form-item{
      margin-bottom: 0px;
      margin-right: 30px;
    }
    .table /deep/ .el-table__expanded-cell .el-form-item__label,.table /deep/ .el-table__expanded-cell .el-form-item__content{
       height: 54px;
       line-height: 54px;
    }
    .menuActive{
      text-align: center;
      color:#3A7654;
      cursor: pointer;
      padding:10px 0;
    }
</style>
